package net.mcreator.servercmd.procedure;

import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.common.MinecraftForge;

import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumHand;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.Entity;

import net.mcreator.servercmd.ElementsServerCmdMod;

import java.util.Map;

@ElementsServerCmdMod.ModElement.Tag
public class ProcedureFixQianYingHe extends ElementsServerCmdMod.ModElement {
	public ProcedureFixQianYingHe(ElementsServerCmdMod instance) {
		super(instance, 21);
	}

	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			System.err.println("Failed to load dependency entity for procedure FixQianYingHe!");
			return;
		}
		if (dependencies.get("x") == null) {
			System.err.println("Failed to load dependency x for procedure FixQianYingHe!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z for procedure FixQianYingHe!");
			return;
		}
		if (dependencies.get("world") == null) {
			System.err.println("Failed to load dependency world for procedure FixQianYingHe!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		int x = (int) dependencies.get("x");
		int z = (int) dependencies.get("z");
		World world = (World) dependencies.get("world");
		String PoxY = "";
		PoxY = (String) "255";
		if (((((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
			int convert(String s) {
				try {
					return Integer.parseInt(s.trim());
				} catch (Exception e) {
				}
				return 0;
			}
		}.convert((PoxY)), (int) z))).getBlock() == Blocks.PURPLE_SHULKER_BOX.getDefaultState().getBlock())
				|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.WHITE_SHULKER_BOX.getDefaultState().getBlock()))
				|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.CYAN_SHULKER_BOX.getDefaultState().getBlock())
						|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.SILVER_SHULKER_BOX.getDefaultState().getBlock())))
				|| ((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.GRAY_SHULKER_BOX.getDefaultState().getBlock())
						|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.PINK_SHULKER_BOX.getDefaultState().getBlock()))
						|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.LIME_SHULKER_BOX.getDefaultState().getBlock())
								|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.YELLOW_SHULKER_BOX.getDefaultState().getBlock()))))
				|| (((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.LIGHT_BLUE_SHULKER_BOX.getDefaultState().getBlock())
						|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.MAGENTA_SHULKER_BOX.getDefaultState().getBlock()))
						|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.ORANGE_SHULKER_BOX.getDefaultState().getBlock())
								|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.BLUE_SHULKER_BOX.getDefaultState().getBlock())))
						|| ((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.BROWN_SHULKER_BOX.getDefaultState().getBlock())
								|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.GREEN_SHULKER_BOX.getDefaultState().getBlock()))
								|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.BLACK_SHULKER_BOX.getDefaultState().getBlock())
										|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
											int convert(String s) {
												try {
													return Integer.parseInt(s.trim());
												} catch (Exception e) {
												}
												return 0;
											}
										}.convert((PoxY)), (int) z))).getBlock() == Blocks.RED_SHULKER_BOX.getDefaultState().getBlock())))))) {
			if (entity instanceof EntityPlayer) {
				ItemStack _setstack = new ItemStack(Blocks.PURPLE_SHULKER_BOX, (int) (1));
				_setstack.setCount(1);
				ItemHandlerHelper.giveItemToPlayer(((EntityPlayer) entity), _setstack);
			}
			if (dependencies.get("event") != null) {
				Object _obj = dependencies.get("event");
				if (_obj instanceof net.minecraftforge.fml.common.eventhandler.Event) {
					net.minecraftforge.fml.common.eventhandler.Event _evt = (net.minecraftforge.fml.common.eventhandler.Event) _obj;
					if (_evt.isCancelable())
						_evt.setCanceled(true);
				}
			}
		}
		PoxY = (String) "0";
		if (((((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
			int convert(String s) {
				try {
					return Integer.parseInt(s.trim());
				} catch (Exception e) {
				}
				return 0;
			}
		}.convert((PoxY)), (int) z))).getBlock() == Blocks.PURPLE_SHULKER_BOX.getDefaultState().getBlock())
				|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.WHITE_SHULKER_BOX.getDefaultState().getBlock()))
				|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.CYAN_SHULKER_BOX.getDefaultState().getBlock())
						|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.SILVER_SHULKER_BOX.getDefaultState().getBlock())))
				|| ((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.GRAY_SHULKER_BOX.getDefaultState().getBlock())
						|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.PINK_SHULKER_BOX.getDefaultState().getBlock()))
						|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.LIME_SHULKER_BOX.getDefaultState().getBlock())
								|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.YELLOW_SHULKER_BOX.getDefaultState().getBlock()))))
				|| (((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
					int convert(String s) {
						try {
							return Integer.parseInt(s.trim());
						} catch (Exception e) {
						}
						return 0;
					}
				}.convert((PoxY)), (int) z))).getBlock() == Blocks.LIGHT_BLUE_SHULKER_BOX.getDefaultState().getBlock())
						|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.MAGENTA_SHULKER_BOX.getDefaultState().getBlock()))
						|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.ORANGE_SHULKER_BOX.getDefaultState().getBlock())
								|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.BLUE_SHULKER_BOX.getDefaultState().getBlock())))
						|| ((((world.getBlockState(new BlockPos((int) x, (int) new Object() {
							int convert(String s) {
								try {
									return Integer.parseInt(s.trim());
								} catch (Exception e) {
								}
								return 0;
							}
						}.convert((PoxY)), (int) z))).getBlock() == Blocks.BROWN_SHULKER_BOX.getDefaultState().getBlock())
								|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.GREEN_SHULKER_BOX.getDefaultState().getBlock()))
								|| (((world.getBlockState(new BlockPos((int) x, (int) new Object() {
									int convert(String s) {
										try {
											return Integer.parseInt(s.trim());
										} catch (Exception e) {
										}
										return 0;
									}
								}.convert((PoxY)), (int) z))).getBlock() == Blocks.BLACK_SHULKER_BOX.getDefaultState().getBlock())
										|| ((world.getBlockState(new BlockPos((int) x, (int) new Object() {
											int convert(String s) {
												try {
													return Integer.parseInt(s.trim());
												} catch (Exception e) {
												}
												return 0;
											}
										}.convert((PoxY)), (int) z))).getBlock() == Blocks.RED_SHULKER_BOX.getDefaultState().getBlock())))))) {
			if (entity instanceof EntityPlayer) {
				ItemStack _setstack = new ItemStack(Blocks.PURPLE_SHULKER_BOX, (int) (1));
				_setstack.setCount(1);
				ItemHandlerHelper.giveItemToPlayer(((EntityPlayer) entity), _setstack);
			}
			if (dependencies.get("event") != null) {
				Object _obj = dependencies.get("event");
				if (_obj instanceof net.minecraftforge.fml.common.eventhandler.Event) {
					net.minecraftforge.fml.common.eventhandler.Event _evt = (net.minecraftforge.fml.common.eventhandler.Event) _obj;
					if (_evt.isCancelable())
						_evt.setCanceled(true);
				}
			}
		}
	}

	@SubscribeEvent
	public void onBlockPlace(BlockEvent.PlaceEvent event) {
		Entity entity = event.getPlayer();
		java.util.HashMap<String, Object> dependencies = new java.util.HashMap<>();
		dependencies.put("ismainhand", event.getHand() == EnumHand.MAIN_HAND);
		dependencies.put("x", (int) event.getPos().getX());
		dependencies.put("y", (int) event.getPos().getY());
		dependencies.put("z", (int) event.getPos().getZ());
		dependencies.put("px", (int) entity.posX);
		dependencies.put("py", (int) entity.posY);
		dependencies.put("pz", (int) entity.posZ);
		dependencies.put("world", event.getWorld());
		dependencies.put("entity", entity);
		dependencies.put("event", event);
		this.executeProcedure(dependencies);
	}

	@Override
	public void preInit(FMLPreInitializationEvent event) {
		MinecraftForge.EVENT_BUS.register(this);
	}
}
